package com.weakteam.orderonline.dataresource.service;

import com.weakteam.orderonline.dataresource.dao.PlaceDAO;
import com.weakteam.orderonline.dataresource.domain.Place;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Nail
 */

@Service
public class PlaceServiceImpl implements PlaceService {

    @Autowired
    private PlaceDAO placeDAO;

    @Transactional
    @Override
    public List<Place> getAll() {
        return placeDAO.getAll();
    }

    @Transactional
    @Override
    public void save(Place place) {
        if (place.getName() == null) {
            place.setName("new place");
        }
        placeDAO.save(place);
    }

    @Transactional
    @Override
    public boolean delete(Integer id) {
        return placeDAO.delete(id);
    }

}
